import instance from '../utils/request'

// 局部导出
// 获取文章列表
export const getArticleList = data => {
  return instance.get('/app/v1_1/articles', { params: data })
}

// 获取新闻文章详情
export const getArticleDetail = articleId => {
  return instance.get(`/app/v1_0/articles/${articleId}`)
}

// 关注用户 target 被关注用户id
export const followUser = target => {
  return instance.post('/app/v1_0/user/followings', { target })
}

// 取消关注用户 target 被取消关注的用户id
export const cancelFollowUser = target => {
  return instance.delete(`/app/v1_0/user/followings/${target}`)
}

// 收藏文章
export const collectArticle = target => {
  return instance.post('/app/v1_0/article/collections', { target })
}

// 取消收藏文章
export const deleteCollectArticle = target => {
  return instance.delete(`/app/v1_0/article/collections/${target}`)
}

// 对文章点赞 用户对文章的态度, -1: 无态度，0-不喜欢，1-点赞
export const likeArticle = target => {
  return instance.post('/app/v1_0/article/likings', { target })
}

// 取消对文章点赞 用户对文章的态度, -1: 无态度，0-不喜欢，1-点赞
export const deleteLikeArticle = target => {
  return instance.delete(`/app/v1_0/article/likings/${target}`)
}
